package edu.ccut.saturn.component.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import edu.ccut.saturn.component.IDataDictTypeInfo;
import edu.ccut.saturn.component.IDictItemInfo;

public class SaturnDataDictTypeInfo implements IDataDictTypeInfo {


	private String name;


	private List<IDictItemInfo> items = null;

	private String type;

	public SaturnDataDictTypeInfo() {

	}

	public SaturnDataDictTypeInfo(IDataDictTypeInfo dataDictTypeInfo) {
		this.name = dataDictTypeInfo.getName();
		this.items = new ArrayList<IDictItemInfo>();
		this.type = dataDictTypeInfo.getType();
		
		List<IDictItemInfo> dictItemList = dataDictTypeInfo.getItems();
		if (dictItemList != null) {
			for (IDictItemInfo dictItem : dictItemList) {
				SaturnDictItemInfo saturnDictItemInfo = new SaturnDictItemInfo(
						dictItem);

				this.items.add(saturnDictItemInfo);
			}
		}
	}

	public String getType() {
		return this.type;
	}

	public String getName() {
		return name;
	}


	public void setItems(List<IDictItemInfo> items) {
		this.items = items;

		if (this.items != null) {
			Collections.sort(this.items);
		}
	}

	public void setType(String key) {
		this.type = key;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<IDictItemInfo> getItems() {
		return this.items;
	}
}
